package com.jzxiang.pickerview.utils;

import ohos.agp.components.Component;

import com.jzxiang.pickerview.data.WheelCalendar;
import com.jzxiang.pickerview.wheel.WheelView;

/**
 * Utils
 *
 * @since 2021-07-16
 */
public class Utils {
    /**
     * isTimeEquals
     *
     * @param calendar calendar
     * @param params params
     * @return boolean
     */
    public static boolean isTimeEquals(WheelCalendar calendar, int... params) {
        switch (params.length) {
            case 1:
                return calendar.year == params[0];
            case 2:
                return calendar.year == params[0] &&
                    calendar.month == params[1];
            case 3:
                return calendar.year == params[0] &&
                    calendar.month == params[1] &&
                    calendar.day == params[2];
            case 4:
                return calendar.year == params[0] &&
                    calendar.month == params[1] &&
                    calendar.day == params[2] &&
                    calendar.hour == params[3];
            default:
                break;
        }
        return false;
    }

    /**
     * hideViews
     *
     * @param views views
     */
    public static void hideViews(WheelView... views) {
        for (int i = 0; i < views.length; i++) {
            views[i].setVisibility(Component.HIDE);
        }
    }

}
